package com.quanquan.management.enums;

/**
 * @author gongzhou
 * @title: CodeEnum
 * @projectName SpringCloud
 * @description: TODO
 * @date 2019/3/2615:30
 */
public enum CodeEnum {

    MOBILE_NULL(-2,"手机号不能为空！"),
    MOBILE_ILLEGAL(-3,"手机号格式不对！"),
    USR_NAME_NULL(-4,"用户不能为空！"),
    PASSWORD_NULL(-5,"密码不能为空！"),
    NO_SUCH_USR(-6,"该用户不存在！"),
    VALID_FAIL(-7,"账号或密码错误"),
    PARAM_LACK(-8,"缺少参数"),
    LOGIN_SUCCESS(1,"登录成功！"),
    LOGIN_FAILED(-1,"服务异常，登录失败！")
            ;
    private Integer code;
    private String msg;

    CodeEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static String getMsgByCode(Integer code) {
        String msg = "";
        CodeEnum[] array = CodeEnum.values();
        for (CodeEnum obj : array) {
            if (code.equals(obj.code)) {
                msg = obj.msg;
                break;
            }
        }
        return msg;
    }
}
